<template>
    <div class="h-end-center">
        <a-popconfirm
            :disabled="popconfirmDisabled"
            title="请确认已保存当前数据，否则将丢失该数据"
            ok-text="是"
            cancel-text="否"
            @confirm="back"
        >
            <a-button v-if="popconfirmDisabled" @click="back" class="mr20">返回</a-button>
            <a-button v-else class="mr20">返回</a-button>
        </a-popconfirm>
        <slot></slot>

        <!--        <a-popconfirm v-if="isShowSave" title="是否保存当前数据?" ok-text="是" cancel-text="否" @confirm="save">-->
        <!--            <a-button class="mr20" :loading="false">保存</a-button>-->
        <!--        </a-popconfirm>-->
        <a-popconfirm v-if="isShowSubmit" title="请确认是否通过?" ok-text="是" cancel-text="否" @confirm="save">
            <a-button class="mr20" :loading="false">通过</a-button>
        </a-popconfirm>

        <a-popconfirm
            v-if="isShowPrevious"
            :disabled="popconfirmDisabled"
            title="请确认已保存当前数据，否则将丢失该数据"
            ok-text="是"
            cancel-text="否"
            @confirm="previousStep"
        >
            <a-button class="mr20" v-if="popconfirmDisabled" @click="previousStep" :type="!isShowNext ? 'primary' : ''">
                上一步
            </a-button>
            <a-button class="mr20" v-else :type="!isShowNext ? 'primary' : ''">上一步</a-button>
        </a-popconfirm>

        <a-popconfirm
            v-if="isShowNext"
            :disabled="popconfirmDisabled"
            title="请确认已保存当前数据，否则将丢失该数据"
            ok-text="是"
            cancel-text="否"
            @confirm="nextStep"
        >
            <a-button v-if="popconfirmDisabled" @click="nextStep" class="mr20" type="primary">下一步</a-button>
            <a-button v-else class="mr20" type="primary">下一步</a-button>
        </a-popconfirm>
    </div>
</template>

<script>
export default {
    name: 'Footer',
    data() {
        return {}
    },
    props: {
        isShowNext: {
            default: true,
            type: Boolean,
        },
        isShowSave: {
            default: true,
            type: Boolean,
        },
        isShowSubmit: {
            default: false,
            type: Boolean,
        },
        cjzt: {},
        isShowPrevious: {
            default: true,
            type: Boolean,
        },
    },
    computed: {
        popconfirmDisabled() {
            return !this.isShowSave || !this.isShowSubmit
        },
    },
    methods: {
        back() {
            this.$emit('back')
        },
        save() {
            this.$emit('save')
        },
        previousStep() {
            this.$emit('previousStep')
        },
        nextStep() {
            this.$emit('nextStep')
        },
    },
}
</script>

<style lang="scss" scoped></style>
